package com.dbb

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

class Shipment {
	String code
	Date loadingDate
	Date eTD
	String containerNo
	String agent
	String boatName
	static hasMany = [groupInfos : GroupInfo]
    static constraints = {
    }
	
	List<Shipment> init() {
		List<Shipment> shipments = new  ArrayList<Shipment>();
		shipments.add(new Shipment("YZ221", new Date(), new Date(), "HJCU9014965/CH940630", "WUXI JIANGTAI", "Hanjin",  GroupInfo.init()));
		return shipments;
	}
	
	private Integer totalCtnNum = 0;
	private Float totalPrice = 0f;
	private Integer totalPairs = 0;
	private Float totalNw = 0f;
	private Float totalGw = 0f;
	private Float totalCbm = 0f;
	
	public void praseGroup() {
		this.groupInfos.each {
			if(it.getRealGroupInfo() != null) {
				it = it.getRealGroupInfo();
			}
			totalPrice += it.getTotalPrice();
			totalPairs += it.getTotalPairs();
			totalNw += it.getTotalNw();
			totalGw += it.getTotalGw();
			totalCbm += it.getTotalCbm();
			totalCtnNum += it.getCtnNum();
		}
	}
	public Float getTotalPrice(){
		return totalPrice ;
	}
	
	public Integer getTotalPairs(){
		return totalPairs;
	}
	
	public Float getTotalNw(){
		return totalNw;
	}
	
	public Float getTotalGw(){
		return totalGw;
	}

	public Float getTotalCbm(){
		return totalCbm;
	}
	
	public Integer getTotalCtnNum(){
		return totalCtnNum;
	}
}
